﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PServiceBus.Core.Interface {
    /// <summary>
    /// Manages retrieval and storing of message in underlying data store
    /// </summary>
    /// <typeparam name="TObject">The type of the object.</typeparam>
    public interface IObjectManager<TObject> : IEnumerable<TObject> where TObject : class, IIdentifiable {
        /// <summary>
        /// Return underlying object provider
        /// </summary>
        IObjectProvider<TObject> Provider { get; set; }
        /// <summary>
        /// Determines whether the underlying data store contains the specified object
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns>
        /// 	<c>true</c> if underlying data store contains the specified object; otherwise, <c>false</c>.
        /// </returns>
        bool Contains(TObject obj);
        /// <summary>
        /// Gets the object that matches the specified id
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        TObject Get(Guid id);
        /// <summary>
        /// Refresh the specified object and add object to underlying data store if it does not exists
        /// </summary>
        /// <param name="obj"></param>
        void Refresh(TObject obj);
        /// <summary>
        /// Attach the specified object to underlying data store.
        /// </summary>
        /// <param name="obj">The obj.</param>
        void Attach(TObject obj);
        /// <summary>
        /// Detaches the specified object from the underlying data store.
        /// </summary>
        /// <param name="obj">The obj.</param>
        void Detach(TObject obj);
        /// <summary>
        /// Append the collection of object to the underlying data source.
        /// </summary>
        /// <param name="objs">The objs.</param>
        void AttachMany(IEnumerable<TObject> objs);
        /// <summary>
        /// Detaches the collection of object from the underlying data source
        /// </summary>
        /// <param name="objs">The objs.</param>
        void DetachMany(IEnumerable<TObject> objs);
        /// <summary>
        /// Clear the data in the current data store
        /// </summary>
        void Clear();
        /// <summary>
        /// Delete the current underlying data store
        /// </summary>
        void Delete();
    }
}
